package com.yoomiito.app.adapter.act.free;

import androidx.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yoomiito.app.R;
import com.yoomiito.app.model.home.PersonalGoodsInfo;
import com.yoomiito.app.utils.ImageLoader;
import com.yoomiito.app.utils.ResUtil;
import com.yoomiito.app.utils.SpannableUtils;

import java.util.List;

public class PersonalGoodsAdapter extends BaseQuickAdapter<PersonalGoodsInfo, BaseViewHolder> {
    public PersonalGoodsAdapter(@Nullable List<PersonalGoodsInfo> data) {
        super(R.layout.item_goods_5, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, PersonalGoodsInfo item) {
        helper.addOnClickListener(R.id.now_buy);
        ImageView goodsPic = helper.getView(R.id.goods_pic);
        ImageLoader.getInstance().into(goodsPic.getContext(), item.getImageUrl(), goodsPic);
        helper.setText(R.id.goods_name, SpannableUtils.getIconAndText(item.getTitle(), ResUtil.getDrawable(item.getSource().equals("1")?R.mipmap.tmall:R.mipmap.tb)));
        helper.setText(R.id.old_goods_price, "原价¥" + SpannableUtils.handlePrice(item.getZkFinalPrice()));
        helper.setText(R.id.now_goods_price, SpannableUtils.getSmallMoneyFlag("¥" + SpannableUtils.handlePrice(item.getDiscountPrice())));

    }
}
